package com.xiang;


import com.baidu.aip.face.AipFace;
import java.util.HashMap;
import org.json.JSONObject;

public class Sample {
  //设置APPID/AK/SK
  public static final String APP_ID = "38136270";
  public static final String API_KEY = "2k2dr4Dp2cMzRgUqh6hC2STW";
  public static final String SECRET_KEY = "3RiODbLEq9jnhLUuUcI59F034mvGofVy";

  public static void main(String[] args) {
    // 初始化一个AipFace
    AipFace client = new AipFace(APP_ID, API_KEY, SECRET_KEY);

    // 可选：设置网络连接参数
    client.setConnectionTimeoutInMillis(2000);
    client.setSocketTimeoutInMillis(60000);

    // 可选：设置代理服务器地址, http和socket二选一，或者均不设置
//    client.setHttpProxy("proxy_host", proxy_port);  // 设置http代理
//    client.setSocketProxy("proxy_host", proxy_port);  // 设置socket代理

    // 调用接口
    String image = "C:\\Users\\zeng_\\Pictures\\645396218.jpg";
    String imageType = "URL";

    // 传入可选参数调用接口
    HashMap<String, Object> options = new HashMap<>();
    options.put("face_field", "age");
    options.put("max_face_num", 2);
    options.put("face_type", "LIVE");
    options.put("liveness_control", "LOW");



    // 人脸检测
    JSONObject res = client.detect(image, imageType, options);
    System.out.println(res.toString(2));

  }
}
